/*******************************************************************************
 * Copyright (c) 2011, 2016 Eurotech and/or its affiliates and others
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Eurotech - initial API and implementation
 *
 *******************************************************************************/
package org.eclipse.kapua.app.console.shared.model;

import java.io.Serializable;
import java.util.Date;

import org.eclipse.kapua.app.console.client.util.DateUtils;

public class GwtDeviceEvent extends KapuaBaseModel implements Serializable
{

    private static final long serialVersionUID = 8453754536105261520L;

    public GwtDeviceEvent()
    {
    }

    @Override
    @SuppressWarnings({ "unchecked" })
    public <X> X get(String property)
    {
        if ("sentOnFormatted".equals(property)) {
            return (X) (DateUtils.formatDateTime((Date) get("sentOn")));
        }
        else if ("receivedOnFormatted".equals(property)) {
            return (X) (DateUtils.formatDateTime((Date) get("receivedOn")));
        }
        else {
            return super.get(property);
        }
    }

    public String getAccountName()
    {
        return (String) get("accountName");
    }

    public void setAccountName(String accountName)
    {
        set("accountName", accountName);
    }

    public String getDeviceId()
    {
        return (String) get("deviceId");
    }

    public void setDeviceId(String deviceId)
    {
        set("deviceId", deviceId);
    }

    public Date getSentOn()
    {
        return (Date) get("sentOn");
    }

    public String getSentOnFormatted()
    {
        return (String) get("sentOnFormatted");
    }

    public void setSentOn(Date sentOn)
    {
        set("sentOn", sentOn);
    }

    public Date getReceivedOn()
    {
        return (Date) get("ReceivedOn");
    }

    public String getReceivedOnFormatted()
    {
        return (String) get("receivedOnFormatted");
    }

    public void setReceivedOn(Date receivedOn)
    {
        set("receivedOn", receivedOn);
    }

    public String getEventType()
    {
        return (String) get("eventType");
    }

    public void setEventType(String eventType)
    {
        set("eventType", eventType);
    }

    public String getEventMessage()
    {
        return (String) get("eventMessage");
    }

    public String getUnescapedEventMessage()
    {
        return getUnescaped("eventMessage");
    }

    public void setEventMessage(String eventMessage)
    {
        set("eventMessage", eventMessage);
    }
}
